﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Core
{
    public enum PhanQuyen 
    {
        Admin,
        NguoiDung
    }
    public class ProxyTaiKhoan
    {
        private List<TaiKhoan> DK = new List<TaiKhoan>(){
            new TaiKhoan(13, "Duc", "12345", 1),new TaiKhoan(14, "phu", "12", 0),new TaiKhoan(15, "cuong", "1234", 0),new TaiKhoan(16, "hai", "123", 1)
            
        };
      

        TaiKhoan _TaiKhoan { get; set; }
        private bool _Login = false;

        FacadeQuanLi FQL = new FacadeQuanLi();

        public ProxyTaiKhoan() { }

        public void Login(TaiKhoan a)
        {
            foreach (var tk in DK)
            {
                if (a.Username == tk.Username && a.Password == tk.Password)
                {
                    _Login = true;
                    return;
                }
            }
                Console.WriteLine("login khong thanh cong");
        }
        public void KiemTraPhanQuyen(TaiKhoan a)
        {

            PhanQuyen pg = (PhanQuyen)Enum.ToObject(typeof(PhanQuyen), a.PhanQuyen);
            //if (_Login==true&& pg==PhanQuyen.Admin)
            //{
            //    FQL.ChucNangNguoiDung();
            //}
            if (_Login == true && pg == PhanQuyen.NguoiDung)
            {
                FQL.ChucNangADmin();
            }
            else
                Console.WriteLine("vui long dang nhap");
        }

    }
}
